package _3_template_method

import "fmt"

type Command interface {
	pre() bool
	run()
	after()
}

//类似于抽象模板
type command struct {
	Command
}

func (c *command) Execute() {
	if c.pre() {
		c.run()
		c.after()
	}
}

type ACommand struct {
	*command
}

func (A *ACommand) pre() bool {
	fmt.Println("ACommand pre")
	return true
}

func (A *ACommand) run() {
	fmt.Println("ACommand run")
}

func (A *ACommand) after() {
	fmt.Println("ACommand after")
}
